package com.gitee.xmhzzz.component.mongodb.core;



import com.gitee.xmhzzz.component.common.enums.PageResult;
import com.gitee.xmhzzz.component.common.enums.Pager;
import org.bson.conversions.Bson;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.aggregation.Aggregation;
import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
import org.springframework.data.mongodb.core.query.Query;

import java.io.Serializable;
import java.util.List;

/**
 * @InterfaceName AbstractMongoRepository
 * @Description
 * @Author wzq
 * @Date 2023/6/16 8:56
 * @Version 1.0
 */
public abstract class AbstractMongoRepository {


    abstract <T> void save(T entity);

    abstract <T> void delete(Class<T> entityClass, Serializable id);

    // abstract <T> void update(T entity, Serializable id) throws Exception;

    abstract <T> T findById(Class<T> entityClass, Serializable id);

    abstract <T> T findOne(Class<T> entityClass, Query query);

    abstract <T> T findUniqueResult(Class<T> entityClass, Query query);

    abstract <T> int getCount(Class<T> entityClass, Query query);

    abstract <T> List<T> searchList(Class<T> entityClass, Query query);

    abstract <T> PageResult<T> searchPage(Class<T> entityClass, Query query, String orderStr, Pager pager);

    abstract <T> List<T> aggregate(Aggregation aggregation, String collectionName, Class<T> outputClass);

    abstract <T> Integer distinctCount(String collectionName, String distinctFileName, Bson filter, Class<T> distinctClass);

    abstract <T> PageResult<T> searchPageWithSort(Class<T> entityClass, Query query, Sort sort, Pager pager);

    abstract <T> PageResult<T> searchWithAggregate(String collectionName, Class<T> outputClass, List<AggregationOperation> operations, Sort sort, Pager pager);


}
